<template>
  <!-- 顶部区域 -->
  <div class="itemMusicTop">
    <!-- 顶部虚化图片 -->
    <img :src="playlist.coverImgUrl" alt="" class="bgimg">
    <div class="itemLeft">
      <van-icon name="arrow-left" size="25" color="#fff" @click="$router.go(-1)" />
      <span>歌单</span>
    </div>
    <div class="itemRight">
      <van-icon name="search" size="25" color="#fff" />
      <van-icon name="wap-nav" size="25" color="#fff" />
    </div>
  </div>
  <!-- 中间区域 -->
  <div class="itemTopContent">
    <div class="contentLeft">
      <img :src="playlist.coverImgUrl" alt="" />
      <div class="palyCount">
        <!-- 播放量 -->
        <van-icon name="service-o" color="#fff" />
        <span>{{changeCount(playlist.playCount)}}</span>
      </div>
    </div>
    <div class="contentRight">
      <p class="rightP_one">{{ playlist.name }}</p>
      <div class="right_img">
        <img :src="playlist.creator.backgroundUrl" alt="" />
        <span>{{ playlist.creator.nickname }}</span>
        <van-icon name="arrow" color="#ccc" />
      </div>
      <p class="rightP_two">
        <span>{{ playlist.description }}</span>
        <van-icon name="arrow" color="#ccc" />
      </p>
    </div>
  </div>
  <!-- 底部区域 -->
  <div class="itemTopFooter">
    <van-tabbar v-model="tab" :fixed="false" :border="false" active-color="#ee0a24">
      <van-tabbar-item icon="more-o"><span>{{ playlist.commentCount }}</span></van-tabbar-item>
      <van-tabbar-item icon="share-o"><span>{{ playlist.shareCount }}</span></van-tabbar-item>
      <van-tabbar-item icon="down"><span>下载</span></van-tabbar-item>
      <van-tabbar-item icon="passed"><span>多选</span></van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import { ref, reactive, onMounted, inject } from 'vue'
// 转变播放量事件js文件
import { changeCount } from '@/utils/changeCount.js'
export default {
  name: 'Top',
  // 利用自定义属性接收Musics传过来的数据
  props: ['playlist'],
  setup(props) {
    // 获取Muscis组件传过来的值
    // let playlist = inject('playlist')

    // 如果判断Musics传过来的值是空对象则直接从本地取数据渲染界面
    if ((props.playlist.creator = '')) {
      props.playlist.creator = JSON.parse(sessionStorage.getItem().playlist).creator
    }
    // 当前标签栏选中按钮的索引
    let active = 0
    let tab = ref(active)
    onMounted(() => {})

    return { changeCount, tab }
  }
}
</script>

<style lang="less" scoped>
.itemMusicTop {
  width: 100%;
  height: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  .itemLeft,
  .itemRight {
    width: 25%;
    height: 100%;
    margin: 0 0.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;

    span {
      font-size: 0.4rem;
      color: #fff;
    }
  }
  .bgimg {
    width: 100%;
    height: 11rem;
    position: fixed;
    z-index: -1;
    filter: blur(30px);
  }
}
.itemTopContent {
  width: 100%;
  height: 3rem;
  padding: 0.2rem;
  margin-top: 0.4rem;
  display: flex;
  justify-content: space-between;
  .contentLeft {
    width: 36%;
    height: 2.6rem;
    position: relative;
    img {
      width: 2.6rem;
      height: 2.6rem;
      border-radius: 0.2rem;
      position: absolute;
      z-index: -1;
    }
    .palyCount {
      text-align: right;
      span {
        font-size: 0.26rem;
        color: #fff;
      }
    }
  }
  .contentRight {
    width: 60%;
    height: 2.6rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .rightP_one {
      font-size: 0.3rem;
      font-weight: 900;
      color: #fff;
      font-family: '微软雅黑';
    }
    .right_img {
      width: 100%;
      height: 0.6rem;
      line-height: 0.6rem;
      color: #ccc;
      img {
        width: 0.6rem;
        height: 0.6rem;
        border-radius: 50%;
        vertical-align: middle;
      }
      span {
        margin-left: 0.1rem;
      }
    }
    .rightP_two {
      width: 100%;
      height: 0.6rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      span {
        display: inline-block;
        width: 95%;
        height: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        font-size: 0.24rem;
        color: #ccc;
      }
    }
  }
}
.itemTopFooter {
  width: 100%;
  height: 1.4rem;
  margin-top: 0.2rem;
  .van-tabbar {
    background-color: rgba(0, 0, 0, 0);
    .van-tabbar-item {
      background-color: rgba(0, 0, 0, 0);
      /deep/ .van-icon {
        font-size: 0.48rem;
        color: #fff;
      }
      span {
        font-size: 0.3rem;
        color: #fff;
      }
    }
  }
}
</style>